home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / RASTER.H < prev    next >
C/C++ Source or Header  |  1992-02-18  |  3KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Raster - rasterized image
  25.  */
  26.  
  27. #ifndef raster_h
  28. #define raster_h
  29.  
  30. #include <InterViews/defs.h>
  31. #include <InterViews/resource.h>
  32.  
  33. class Color;
  34. class Canvas;
  35.  
  36. class Raster : public Resource {
  37. public:
  38.     Raster(Color** data, int width, int height);
  39.     Raster(Canvas*, int x0, int y0, int width, int height);
  40.     Raster(Raster*);
  41.     ~Raster();
  42.  
  43.     int Width();
  44.     int Height();
  45.     boolean Contains(int x, int y);
  46.     Index(int x, int y);
  47.  
  48.     Color* Peek(int x, int y);
  49.     void Poke(Color*, int x, int y);
  50. protected:
  51.     friend class Painter;
  52.  
  53.     Color** raster;
  54.     class RasterRep* rep;
  55. };
  56.  
  57. class RasterRep {
  58. private:
  59.     friend class Raster;
  60.     friend class Painter;
  61.  
  62.     RasterRep(int w, int h);
  63.     RasterRep(Canvas*, int x0, int y0, int w, int h);
  64.     RasterRep(RasterRep*);
  65.     ~RasterRep();
  66.  
  67.     long unsigned GetPixel(int x, int y);
  68.     void PutPixel(int x, int y, Color*);
  69.     void* GetData();
  70.  
  71.     int width;
  72.     int height;
  73.     void* data;
  74. };
  75.  
  76. inline int Raster::Width () { return rep->width; }
  77. inline int Raster::Height () { return rep->height; }
  78. inline boolean Raster::Contains (int x, int y) {
  79.     return x >= 0 && x < Width() && y >= 0 && y < Height();
  80. }
  81. inline int Raster::Index (int x, int y) { return y * Width() + x; }
  82.  
  83.  
  84. #endif
  85.